package UseCollection.UseList.ArrayList01;

import java.util.ArrayList;
import java.util.Scanner;

public class ArrayListPractice03 {
    public static void main(String[] args) {
        ArrayList<Student> stus = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            Student s = new Student();
            System.out.println("请输入姓名");
            String name = sc.next();
            System.out.println("请输入年龄");
            int age = sc.nextInt();
            s.setName(name);
            s.setAge(age);
            stus.add(s);
        }
        for (int i = 0; i < stus.size(); i++) {
            Student s = stus.get(i);
            System.out.println(s.getName()+","+s.getAge());

        }
    }
}
class Student{
    private String name;
    private int age;

    public Student() {
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}